package com.wtwd.campus.dao;

import com.wtwd.campus.entity.CommandRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @Author ldaoliang
 * @Date create in 15:08 2021/6/10
 * @Description
 */
@Mapper
public interface CommandRecordMapper {

    // 保存指令下发记录
    int saveCommandRecord(CommandRecord commandRecord);

    // 完善指令下发记录
    int completeCommandRecord(@Param("data") CommandRecord data);

    // 根据imei,commandType,commandNumber,查询未完成指令下发记录
    CommandRecord getNotCompleteCommandRecordByCondition(@Param("imei") String imei, @Param("commandType") String commandType,
                                                         @Param("commandNumber") String commandNumber);

    //根据设备imei号查询离线存储指令
    List<CommandRecord> getOffLineSendCommand(String imei);

    //修改离线发送指令的状态
    Integer modifyOffLineSendCommand(@Param("data") CommandRecord data);

    //删除同一类型的离线且未发送的指令记录
    Integer deleteCommandRecord(@Param("type") String type,@Param("imei") String imei);

    //保存离线缓存记录表
    Integer saveOfflineCommandRecord(@Param("data") CommandRecord data);

    //修改指令下发记录表中的离线下发指令
    Integer modifyOffLineCommandRecordParam(@Param("data") CommandRecord data);

    //根据离线缓存记录id 获取指令下发记录表中记录
    CommandRecord getCommandRecordByOfflineId(Integer offLineId);

    //修改指令发送的记录的状态
    Integer modifyCommandRecordResult(@Param("data") CommandRecord data);

    //根据指令类别、imei、流水号、序列号修改指令下发记录的状态
    Integer modifyCommandRecordResultByCondition(@Param("data") CommandRecord data );

    //根据设备imei获取定位模式和睡眠模式的最后一笔记录
    List<CommandRecord> getSpecialRecordByImei(@Param("imei") String imei,@Param("list") List<String> typeList);



    Integer completeCommand(@Param("id") Integer id,@Param("time") long time);

    CommandRecord getCommandRecordByCondition(@Param("imei") String imei,@Param("sequence") Integer sequence,@Param("commandTypeList") List<String> commandTypeList,@Param("commandNumber")String commandNumber);


    CommandRecord getCommandRecordByCondition2(@Param("imei") String imei,@Param("commandNumber") String commandNumber, @Param("commandType") String commandType);

    Integer delWhiteByCondition(@Param("deviceId") Integer deviceId,@Param("sequence") Integer seq,@Param("status") Integer status );

    Integer getDeviceWhiteListByCondition(@Param("deviceId") Integer deviceId,@Param("sequence") Integer seq);

    Integer completeDeviceWhiteStatus(@Param("deviceId") Integer deviceId,@Param("sequence") Integer seq,@Param("status") Integer status);

    Integer getDeviceClassPatternByCondition(@Param("deviceId") Integer deviceId,@Param("sequence") Integer seq);

    Integer delDeviceClassPatternByCondition(@Param("deviceId") Integer deviceId,@Param("sequence") Integer seq);

    Integer completeDeviceClassPatternStatus(@Param("deviceId") Integer deviceId,@Param("sequence") Integer seq,@Param("status") Integer status);

    Integer delWhiteListByCondition(@Param("deviceId") Integer deviceId,@Param("status") Integer status,@Param("list") List<Integer> list);

    Integer updateWhiteListStatusByCondition(@Param("deviceId") Integer deviceId,@Param("status") Integer status,@Param("list") List<Integer> list);

    /**
     * 1.为缓存数据
     * 3.为指令失败状态
     * @param imei
     * @param cmd
     * @return
     */
    Integer deleteCacheCmd(@Param("imei") String imei, @Param("cmd")String cmd);
}
